<%-- web/blogdetail.jsp --%>
<%-- blogdetail.jsp --%>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page isELIgnored="false" %> <!-- 确保EL生效 -->




<html>
<head>
  <title>留言详情</title>
  <style>
    /* 完整样式（与bloglist.jsp一致） */
    body {
      margin: 0;
      font-family: 'Segoe UI', system-ui;
      min-height: 100vh;
      background: linear-gradient(rgba(255,255,255,0.9), rgba(255,255,255,0.9)), url('pic/bg.jpg');
      background-size: cover;
      background-attachment: fixed;
      color: #333;
    }

    .container {
      max-width: 1200px;
      margin: 0 auto;
      padding: 2rem;
    }

    .blog-detail {
      background: rgba(255,255,255,0.98);
      border-radius: 12px;
      padding: 2rem;
      box-shadow: 0 5px 20px rgba(0,0,0,0.15);
      position: relative;
      margin-top: 1rem;
    }

    .btn {
      padding: 0.8rem 1.5rem;
      border: none;
      border-radius: 25px;
      cursor: pointer;
      transition: transform 0.2s, box-shadow 0.2s;
      text-decoration: none;
    }

    .btn-secondary {
      background: #ecf0f1;
      color: #2c3e50;
    }

    .blog-meta {
      margin-top: 1rem;
      font-size: 0.9rem;
      color: #95a5a6;
    }

    .detail-content {
      white-space: pre-wrap;
      line-height: 1.8;
      font-size: 1.1rem;
      margin: 1.5rem 0;
      padding: 1rem;
      background: #f8f9fa;
      border-radius: 8px;
    }
  </style>
</head>
<body>
<div class="container">
  <c:choose>
    <%-- 处理blog为空的情况 --%>
    <c:when test="${empty blog}">
      <div class="error-message" style="color: red; text-align: center; padding: 2rem;">
        <h2>⚠️ 内容不存在</h2>
        <p>您查看的留言已被删除或不存在</p>
        <a href="blog" class="btn btn-secondary">返回列表</a>
      </div>
    </c:when>
    <c:otherwise>
      <div class="blog-detail">
        <a href="blog" class="btn btn-secondary" style="position: absolute; top: 1rem; right: 1rem;">← 返回列表</a>
        <h1>${blog.title}</h1>
        <div class="blog-meta">
          发布于
          <fmt:formatDate value="${blog.createTime}" pattern="yyyy-MM-dd HH:mm"/>
        </div>
        <pre class="detail-content">${blog.content}</pre>
      </div>
    </c:otherwise>
  </c:choose>
</div>
</body>
</html>